<?php

namespace View;

class RegisterView {
	
	private $m_username = 'username';
	private $m_password = 'password';
	private $m_password2 = 'password2';
	private $m_registerButton = 'registerButton';
	
	
	//Returnerar registreingsformulär
	public function RegisterUserBox(){
	
		if (isset($_SESSION['m_username'])&& isset($_POST[$this->m_username])){
			$_SESSION['m_username'] = $_POST[$this->m_username];
		} else {
			$_SESSION['m_username'] = "";
		}
		return
		'<div id=register>
		<h2>Register new user</h2>
		<form method="post">
			    <fieldset>
					<label class=label>Username:</label> 
					<input type="text" name="'.$this->m_username.'" value="'.$_SESSION['m_username'].'" /><br />
					<label class=label>Password:</label> 
					<input type="password" name="'.$this->m_password.'" /><br />
					<label class=label>Verify Password:</label> 
					<input type="password" name="'.$this->m_password2.'" /><br />
					<input type="submit" value="Register" id=registerbutton name="'.$this->m_registerButton.'"/>
				</fieldset>
		 </form>
		 </div>';
		
	}
	//Returnerar användarnamnet
	public function GetUsername(){
		if(isset($_POST[$this->m_username])){
			return $_POST[$this->m_username];
		}
	}
	//Returnerar lösenordet
	public function GetPassword(){
		if (isset($_POST[$this->m_password])){
			return $_POST[$this->m_password];
		}
	}
	//Returnerar verifierat lösenord
	public function GetPassword2(){
		if (isset($_POST[$this->m_password2])){
			return $_POST[$this->m_password2];
		}
	}
	//Har användaren klickat på registrera
	public function TriedToRegister(){
		if (isset($_POST[$this->m_registerButton])){
			return true;
		}
		return false;
	}
	
	//Fel/rätt meddelanden
	public function SuccessMessage(){
		$message = "<p class=registredMessage>You are now registred!</p>";
		return $message;
	}
	
	public function WrongUsernameMessage(){
		$message = "Invalid username";
		return $message;
	}
	
	public function WrongPassword(){
		$message = "Invalid password";
		return $message;
	}
	
	public function UserExistMessage(){
		$message = "<p class=message>Username already exists</p>";
		return $message;
	}
	

}
